From: Florian Müllner Date: Fri, 30 Sep 2011 16:54:45 +0000 (+0200) Subject: user-menu: Restore previous IM presence on startup X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~7486 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=39c5d23a871fb2b3e2a7860162ff56284c2f2226;p=gnome-shell.git user-menu: Restore previous IM presence on startup Move the saved user-set presence to GSettings, so it is preserved between logins. https://bugzilla.gnome.org/show_bug.cgi?id=659021 --- diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in index 55db42a89..a848818d2 100644 --- a/data/org.gnome.shell.gschema.xml.in +++ b/data/org.gnome.shell.gschema.xml.in @@ -50,6 +50,10 @@ [] <_summary>History for the looking glass dialog + + 0 + <_summary> + diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index 22988faba..85d98028e 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -163,17 +163,23 @@ IMStatusChooserItem.prototype = { Lang.bind(this, this._sessionStatusChanged)); this._currentPresence = undefined; - this._previousPresence = undefined; this._accountMgr = Tp.AccountManager.dup() this._accountMgr.connect('most-available-presence-changed', Lang.bind(this, this._IMStatusChanged)); this._accountMgr.prepare_async(null, Lang.bind(this, function(mgr) { - let [presence, s, msg] = mgr.get_most_available_presence(); - - this._previousPresence = presence; - this._IMStatusChanged(mgr, presence, s, msg); + let [presence, status, msg] = mgr.get_most_available_presence(); + + let savedPresence = global.settings.get_int('saved-im-presence'); + if (savedPresence == presence) { + this._IMStatusChanged(mgr, presence, status, msg); + } else { + this._setComboboxPresence(savedPresence); + status = this._statusForPresence(savedPresence); + msg = msg ? msg : ''; + mgr.set_all_requested_presences(savedPresence, status, msg); + } })); this._userManager = AccountsService.UserManager.get_default(); @@ -265,15 +271,18 @@ IMStatusChooserItem.prototype = { return; this._currentPresence = presence; + this._setComboboxPresence(presence); if (presence == Tp.ConnectionPresenceType.AVAILABLE) this._presence.setStatus(GnomeSession.PresenceStatus.AVAILABLE); if (!this._expectedPresence || presence != this._expectedPresence) - this._previousPresence = presence; + global.settings.set_int('saved-im-presence', presence); else this._expectedPresence = undefined; + }, + _setComboboxPresence: function(presence) { let activatedItem; if (presence == Tp.ConnectionPresenceType.AVAILABLE) @@ -315,8 +324,11 @@ IMStatusChooserItem.prototype = { }, getIMPresenceForSessionStatus: function(sessionStatus) { + // Restore the last user-set presence when coming back from + // BUSY/IDLE (otherwise the last user-set presence matches + // the current one) if (sessionStatus == GnomeSession.PresenceStatus.AVAILABLE) - return this._previousPresence; + return global.settings.get_int('saved-im-presence'); if (sessionStatus == GnomeSession.PresenceStatus.BUSY) { // Only change presence if the current one is "more present" than